package com.usian.service.impl;

import com.usian.mapper.OrderMaapper;
import com.usian.pojo.Order;
import com.usian.service.OrderService;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMaapper orderMaapper;
    @Autowired
    private RestTemplate restTemplate;
    @Override
    public Order findByid(Long id) {
        Order order= orderMaapper.selectByid(id);
        User user = restTemplate.getForObject("http://userservice/user/" + order.getUserId(), User.class);
        order.setUser(user);
        return order;
    }
}
